package cn.iocoder.yudao.module.pickbook.dal.mysql.userreadinghistory;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.pickbook.controller.admin.userreadinghistory.vo.UserReadingHistoryPageReqVO;
import cn.iocoder.yudao.module.pickbook.dal.dataobject.userreadinghistory.UserReadingHistoryDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户阅读记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface UserReadingHistoryMapper extends BaseMapperX<UserReadingHistoryDO> {

    default PageResult<UserReadingHistoryDO> selectPage(UserReadingHistoryPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserReadingHistoryDO>()
                .eqIfPresent(UserReadingHistoryDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserReadingHistoryDO::getBookId, reqVO.getBookId())
                .eqIfPresent(UserReadingHistoryDO::getIsCompleted, reqVO.getIsCompleted())
                .orderByDesc(UserReadingHistoryDO::getId));
    }

}